#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>
int main()
{
	char arr[10001];

	while (gets(arr) != NULL)
	{
		size_t len = strlen(arr);
		int fz = 0;
		scanf("%d", &fz);
		for (int i = 1; i <= fz; i++)
		{
			char t = arr[len - 1];
			for (int j = len - 2; j >= 0; j--)
			{
				arr[j + 1] = arr[j];
			}
			arr[0] = t;
		}
		for (int i = 0; i < len; i++)
			printf("%c", arr[i]);
		printf("\n");
	}
	return 0;
}